export default {
  state: {
    currentMenu: null,
    isCollapse: false,
    tabsList: [
      {
        path: "/Home",
        name: "Home",
        label: "首页",
        icon: "Home"
      }
    ]
  },
  mutations: {
    selectMenu(state, val) {
      if (val.name !== "Home") {
        state.currentMenu = val;
        let result = state.tabsList.findIndex(item => item.name === val.name);
        result === -1 ? state.tabsList.push(val) : "";
      } else {
        state.currentMenu = null;
      }
    },
    collapseMenu(state) {
      state.isCollapse = !state.isCollapse;
    },
    //关闭标签
    closeTab(state, val) {
      let result = state.tabsList.findIndex(item => item.name === val.name);
      state.tabsList.splice(result, 1);
    }
  },
  actions: {}
};
